import combineRoutes from 'koa-combine-routers'

// import publicRouter from './publicRouter'
// console.log('TCL: publicRouter',publicRouter);
// import loginRouter from './loginRouter'
// import userRouter from './userRouter'
// import listRouter from './listRouter'


// 加载目录中的Router中间件
const moduleFiles = require.context('./modules', true, /\.js$/)
//reduce方法拼接KOA-combine-router所需的数据结构obj[]
const modules = moduleFiles.keys().reduce((items, path)=>{
    const val = moduleFiles(path)
    // console.log(val.default);
    items.push(val.default)
    return items
},[])
// console.log('TCL: modules' , modules);

export default combineRoutes(
    modules
    // publicRouter, 
    // loginRouter
    // userRouter,
    // listRouter
    )
